%EntityIsTransaction.tex
\lstset{language=[Sharp]c}
\begin{lstlisting}[frame=single]
using (var context = new dmaa0212a_3Entities15())
{
	Seat tempSeat = context.Seat.First(s => s.SeatID == i);
	HasSeats temp = context.HasSeats.First(s => s.IdSeat == tempSeat.SeatID);
	result.Add(new SeatDTO()
	{
		HallId = tempSeat.Hall,
		HallRow = tempSeat.TRow.Id,
		SeatId = tempSeat.SeatID,
		SeatNumeber = tempSeat.Number,
		SeatState = temp.SeatState
	});
	context.SaveChanges();
}
\end{lstlisting}

\noindent Svarer til

\lstset{language=Sql}
\begin{lstlisting}[frame=single]
exec sp_executesql N'insert [dbo].[Reservation]([UserID], [Show], [Hall], [_Time], [Seats], [Paid])
values (@0, @1, @2, @3, @4, @5)
select [Id]
from [dbo].[Reservation]
where @@ROWCOUNT > 0 and [Id] = scope_identity()',N'@0 int,@1 int,@2 int,@3 datetime2(7),@4 int,@5 bit',@0=1,@1=1,@2=1,@3='2013-03-15 18:00:00',@4=6,@5=0
\end{lstlisting}

\begin{quotation}
\noindent \textbf{sp_executesql (Transact-SQL)}

\noindent Executes a Transact-SQL statement or batch that can be reused many times, or one that has been built dynamically. The Transact-SQL statement or batch can contain embedded parameters.
\begin{verbatim}
http://msdn.microsoft.com/en-us/library/ms188001.aspx
\end{verbatim}
\end{quotation}